//
//  ConnactImageCell.swift
//  AESOLAR_IOS
//
//  Created by Mac on 2019/8/22.
//  Copyright © 2019 Mr.Wang. All rights reserved.
//

import UIKit

class ConnactImageCell: UICollectionViewCell {
    
    let imageView = UIImageView()
    let videoIcon = UIImageView()
    let deleteButton = UIButton()
    var deleteBlock: () -> () = { }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        imageView.config
            .contentMode(.scaleAspectFill)
            .clipsToBounds(true)
            .addTo(self)
            .makeConstraints { (make) in
                make.left.bottom.equalToSuperview()
                make.top.equalTo(10)
                make.right.equalTo(-10)
        }
        
        videoIcon.config
            .imageName("play_button")
            .isHidden(true)
            .addTo(self)
            .makeConstraints { (make) in
                make.center.equalTo(imageView.snp.center)
                make.height.width.equalTo(40)
        }
        
        deleteButton.config
            .backgroundImage(UIImage.init(named: "error_image"))
            .cornerRadius(10)
            .clipsToBounds(true)
            .addTarget(self, action: #selector(deleteButtonClick))
            .addTo(self)
            .makeConstraints { (make) in
                make.width.height.equalTo(20)
                make.top.right.equalToSuperview()
        }
    }
    
    @objc func deleteButtonClick() {
        deleteBlock()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
